<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');

class pqcesModelpqces extends JModel
{
	function __construct()
	{
		parent::__construct();
		$this->_data	= null;
	global $option;
	$app=&JFactory::getApplication();
        $filter_order     = $app->getUserStateFromRequest(  $option.'filter_order', 'filter_order', 'id', 'cmd' );
        $filter_order_Dir = $app->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', 'asc', 'word' );
        $this->setState('filter_order', $filter_order);
        $this->setState('filter_order_Dir', $filter_order_Dir);

	}
	function &getData()
	{
                $orderby = '';
                $filter_order     = $this->getState('filter_order');
                $filter_order_Dir = $this->getState('filter_order_Dir');
 
                if(!empty($filter_order) && !empty($filter_order_Dir) ){
                        $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir;
                }
		if (empty( $this->_data )) {
			$query = ' SELECT * FROM #__qcalendar'.$orderby;
			$this->_db->setQuery( $query );
			$this->_data = $this->_db->loadObjectList();
		}
		if (!$this->_data) {
			$tmpC=new stdClass();
			$tmpC->id = 0;
			$tmpC->type = 0;
			$tmpC->link = null;
			$tmpC->url = null;
			$tmpC->refdate = '0000-00-00';
			$tmpC->hr = null;
			$tmpC->min = null;
			$tmpC->category_id = null;
			$tmpC->email_alert = null;
			$tmpC->cron_email = null;
			$tmpC->short_desc = null;
			$tmpC->long_desc = null;
			$tmpC->short_desc_image = null;
			$tmpC->long_desc_image = null;
			$tmpC->active = null;
			$this->_data= array($tmpC);
		}
		return $this->_data;
	}
}
